Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MkBlockQuote

github Show source on GitHub

BlockQuote node.

Examples

Example: Regular

Note

Jinja

{{ "Some text" | MkBlockQuote }}

Note

Python

MkBlockQuote()
Rendered

Some text

Markdown
> Some text

Html
<blockquote>
<p>Some text</p>
</blockquote>

reST
    Some text

Repr tree
MkBlockQuote
╰── MkText('Some text')

Example: Nested

Note

Jinja

{{ "Nested!" | MkBlockQuote | MkBlockQuote }}

Note

Python

MkContainer()
Rendered

Nested!

Nested!

Markdown
> Nested!

> > Nested!

Html
<blockquote>
<p>Nested!</p>
</blockquote>
<blockquote>
<blockquote>
<p>Nested!</p>
</blockquote>
</blockquote>

Repr tree
MkContainer
├── MkBlockQuote()
│   ╰── MkText('Nested!')
╰── MkBlockQuote()
├── MkBlockQuote()
│   ╰── MkText('Nested!')
DocStrings

class MkBlockQuote(mkcontainer.MkContainer)
Base classes
NameChildrenInherits
MkContainer
mknodes.basenodes.mkcontainer
A node containing other MkNodes.
⋔ Inheritance diagram
graph TD
  1647548858["mkblockquote.MkBlockQuote"]
  835538629["mkcontainer.MkContainer"]
  1956333208["mkcontainer.MkContainerBase"]
  1359323199["mknode.MkNode"]
  2751680898["builtins.object"]
  835538629 --> 1647548858
  1956333208 --> 835538629
  1359323199 --> 1956333208
  2751680898 --> 1359323199
NodeFile

/home/runner/work/mknodes/mknodes/src/mknodes/basenodes/mkblockquote/metadata.toml

[metadata]
icon = "mdi:format-quote-open"
name = "MkBlockQuote"

[examples.regular]
title = "Regular"
jinja = """
{{ "Some text" | MkBlockQuote }}
"""

[examples.nested]
title = "Nested"
description = "We can also nest blocks, they will adjust their delimiters automatically."
jinja = """
{{ "Nested!" | MkBlockQuote | MkBlockQuote }}
"""

[output.markdown]
template = """
{{ node.get_items() | join(node.block_separator) | indent(width="> ", first=True) | rstrip("\n") }}

"""

# [output.html]
# template = """
# <blockquote>
# {{ node.get_items() | join(node.block_separator)  }}
# </blockquote>
# """

[output.rst]
template = """
{{ node.get_items() | join(node.block_separator) | indent(width="    ", first=True) | rstrip("\n") }}

"""

Code

mknodes.basenodes.mkblockquote.MkBlockQuote

class MkBlockQuote(mkcontainer.MkContainer):
    """BlockQuote node."""

    ICON = "material/format-quote-open"
    STATUS = "new"

    def get_content(self) -> resources.NodeContent:
        """Single-pass: get content and apply blockquote indentation."""
        content = super().get_content()
        md = textwrap.indent(content.markdown, "> ").rstrip("\n") + "\n"
        return resources.NodeContent(markdown=md, resources=content.resources)

    def to_md_unprocessed(self) -> str:
        content = self.get_content()
        return content.markdown

Page info
Code for this page

mknodes.manual.nodes_section.create_section_for_nodes

def create_section_for_nodes(
    nav: mk.MkNav,
    klasses: Sequence[type[mk.MkNode]],
) -> mk.MkTable:
    table = mk.MkTable(columns=["Node", "Docstrings", "Markdown extensions"])
    for kls in klasses:
        tpl = "classpage_custom.jinja"
        page = mk.MkClassPage(kls, icon=kls.ICON, template_path=tpl, parent=nav, hide="toc")
        nav += page
        if kls.STATUS:
            page.metadata.status = kls.STATUS
        elif kls.JS_FILES:
            page.metadata.status = "js"
        elif kls.CSS:
            page.metadata.status = "css"
        page.created_by = create_section_for_nodes
        link = mk.MkLink(page, kls.__name__, icon=kls.ICON)
        extensions = ", ".join(f"`{i}`" for i in kls.REQUIRED_EXTENSIONS)
        table.add_row((link, kls.__doc__, extensions))
    return table

Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'pymdownx.details': {},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
                                                                           'format': <function fence_code_format at 0x7d707a397060>,
                                                                           'name': 'mermaid'}]},
                               'pymdownx.tabbed': {},
                               'tables': {}},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
  source_function: create_section_for_nodes
  source_line_no: 93
hide:
- toc
icon: material/format-quote-open
status: new
title: MkBlockQuote